package leetcode.median;

import java.util.LinkedList;
import java.util.List;
import java.util.zip.CRC32;

public class $784_LetterCasePermutation {

    List<String> res = new LinkedList<>();


    public List<String> letterCasePermutation(String s) {
        if (s.length() == 0) {
            return res;
        }
        dfs(s.toCharArray(), 0);
        return res;
    }

    public void dfs(char[] arr, int curIndex) {
        res.add(new String(arr));


        for (int i = curIndex;i < arr.length;i++) {
            char curChar = arr[i];
            if (curChar >= 'a' && curChar <= 'z') {
                arr[i] = (char) (curChar - ' ');
                dfs(arr, i + 1);
                arr[i] = curChar;
            } else if (curChar >= 'A' && curChar <= 'Z') {
                arr[i] = (char) (curChar + ' ');
                dfs(arr, i + 1);
                arr[i] = curChar;
            }
        }
    }
}
